package com.rs.game.player.content;

import com.rs.game.WorldTile;
import com.rs.game.npc.NPC;
import com.rs.game.player.Player;
import com.rs.utils.Utils;

public class NPCSearch {
	
	private static int MAX_RESULTS = 50;
	
	public static void searchForNPC(Player player, String npcName) {
    	int count = 0;
        for (int i = 0; i < Utils.getNPCDefinitionsSize(); i++) {
		   NPC npc = new NPC(i, new WorldTile(-1, -1 , -1), 0, false);
		   if (npc.getDefinitions().getName().toLowerCase().contains(npcName.toLowerCase())) {
		    count++;
		    if (count == MAX_RESULTS) {
		     player.getPackets().sendPanelBoxMessage("<col=FF0000>Found over 50 results for " + Utils.formatPlayerNameForDisplay(npcName) + ". Only 50 listed.");
		     return;
		    }
		    player.getPackets().sendPanelBoxMessage("<col=FF0000>"+Utils.formatPlayerNameForDisplay(npc.getName()) + " (Id: " + npc.getId()+"</col>)");
		   }
		  }
		  player.getPackets().sendPanelBoxMessage("<col=FF0000>Found " + count + " results for the npc " + Utils.formatPlayerNameForDisplay(npcName) + ".");
		 }
}